package com.bip.it;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebViewActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        final HttpClient client = MainActivity.httpclient;
        CookieSyncManager.createInstance(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview_activity);
        final WebView webView = (WebView)findViewById(R.id.webview_activity_webview);
        Bundle extras = getIntent().getExtras();
        if(extras != null) {
             String htmlString = extras.getString("htmlString");
             
             webView.setWebChromeClient(new WebChromeClient());     
             webView.setWebViewClient(new WebViewClient(){
                 @Override
                 public boolean shouldOverrideUrlLoading(WebView view, String url){

                     String LinkTag = "";
                     try {
                         LinkTag = client.httpGet(url);
                         client.
                     } catch (ClientProtocolException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
                     } catch (URISyntaxException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
                     } catch (IOException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
                     }

                     webView.loadDataWithBaseURL("BaseWebUrl", LinkTag, "text/html", "utf-8", "");
                     return true;
                 }
             });
             WebSettings webSettings = webView.getSettings();
             webSettings.setJavaScriptEnabled(true);
             webView.loadData(htmlString, "text/html", "utf-8");
        }
    }

}
